package net.betou.cms.manager.assist.impl;

import net.betou.cms.dao.assist.CmsGuestbookExtDao;
import net.betou.cms.entity.assist.CmsGuestbook;
import net.betou.cms.entity.assist.CmsGuestbookExt;
import net.betou.cms.manager.assist.CmsGuestbookExtMng;
import net.betou.common.hibernate3.Updater;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CmsGuestbookExtMngImpl implements CmsGuestbookExtMng{
	public CmsGuestbookExt save( CmsGuestbookExt ext, CmsGuestbook guestbook ) {
		guestbook.setExt( ext );
		ext.setGuestbook( guestbook );
		ext.init( );
		dao.save( ext );
		return ext;
	}

	public CmsGuestbookExt update( CmsGuestbookExt ext ) {
		Updater< CmsGuestbookExt > updater = new Updater< CmsGuestbookExt >( ext );
		CmsGuestbookExt entity = dao.updateByUpdater( updater );
		entity.blankToNull( );
		return entity;
	}

	private CmsGuestbookExtDao dao;

	@Autowired
	public void setDao( CmsGuestbookExtDao dao ) {
		this.dao = dao;
	}
}